<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<select name="" value="" id="select">
			<option value ="">请选择大小</option>
			<option value="1">大</option>
			<option value ="2">小</option>
		</select></br>
		<img src="img/摇色子/1.jpg" id="imgadd" ></br>
		<button type="button" onclick="bb()">开始/暂停</button>
	</body>
		<script type="text/javascript">
		function bb(){
			var sifter =document.getElementById("select");
			if(sifter.value == ""){
				alert("请选择大小")
			}
			else{
				var img=document.getElementById("imgadd");
				var num=0;
				var	whom=setInterval(function(){
						var img1  = cc();
						img.src="img/摇色子/"+img1+".jpg";
						console.log('公布抽奖结果:'+img1);
						
						num++;
						if(num=5){
							clearInterval(whom)
							switch (img1){
								case img1=1: 
								if(sifter.value == 2){
									alert("你猜对了");
								}else{
									alert("你猜错了")
								}
									
									break;
								case img1=2:
								if(sifter.value == 2){
									alert("你猜对了");
								}else{
									alert("你猜错了")
								}
									
									break;
								case img1=3:
									if(sifter.value == 2){
										alert("你猜对了");
									}else{
										alert("你猜错了")
									}
									break;
								case img1=4:
									if(sifter.value == 1){
										alert("你猜对了");
									}else{
										alert("你猜错了")
									}
									break;
								case img1=5:
									if(sifter.value == 1){
										alert("你猜对了");
									}else{
										alert("你猜错了")
									}
									break;
								case img1=6:
									if(sifter.value == 1){
										alert("你猜对了");
									}else{
										alert("你猜错了")
									}
									break;
								default:
								alert("异常")
									break;
							}
						}
					},500)
			}
			
	
			}
			function cc(){
				while(true){
					var img1 = Math.floor(Math.random()*7);
					if(img1!=0){
						return img1;
					}
			}
			}
			
		</script>
</html>
